prepare($sql);
$stmt->bindValue(':bibno', $bibno, PDO::PARAM_INT);
$stmt->execute();
$runner = $stmt->fetch(PDO::FETCH_ASSOC);
$name = displayFirstLastname( $runner['firstname'], $runner['lastname']);
if (!$runner) {
die("participant not exist");
}
if ($runner['course'] == 'UTMT')
{
$course= "Ultra-Trail® TAI MO SHAN, UTMT, for 162km ";
$course= "UTMT 162km";
}
if ($runner['course'] == 'TTF')
{
$course= "TSUEN WAN to FO TAN, TTF, for 115km ";
$course= "TTF 115km";
}
if ($runner['course'] == 'YTF')
{
$course= "YUEN LONG to FO TAN, YTF, for 50km ";
$course= "YTF 50km";
}
// ---------------------------------------------------------
$sql = "select *
from
". $table_prefix. "trackrecord_summary
where
bibno = '" . $bibno . "'
and cp_code = 'FP'
order by cp_count";
$stmt = $db->prepare($sql);
// $stmt->bindValue(':bibno', $bibno, PDO::PARAM_STR);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$result['duration']) {
die("no finish time avaible");
}
$finishtime = Duration($result['duration']);
/*--------------------------------------------*/
$catname = $runner['group_name_en'] . ' ' . i18n_text( $runner['gender'] . '_group');
$rank_cat = $result['place_gender_group'];
$rank_course = $result['place_course'];
/*--------------------------------------------*/
$pdf = new FPDI('L', 'mm', 'A4'); //FPDI extends TCPDF
$pdf->AddPage();
$pages = $pdf->setSourceFile('UTMTCert2017OP.pdf');
$page = $pdf->ImportPage(1);
//$pdf->useTemplate($page, 0, 0);
$pdf->useTemplate($page,null, null, 0, 0, true);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('SportSystem.hk');
$pdf->SetTitle('Certificate');
$pdf->SetSubject('Certificate of '. $name);
$pdf->SetKeywords('UTMT' );
// ---------------------------------------------------------
// set font
//$pdf->SetFont('helvetica', '', 20);
if (strlen($name) > 23 )
{
$pdf->SetFont('DroidSansFallback', '', 25, '', true);
} else {
$pdf->SetFont('DroidSansFallback', '', 30, '', true);
}
$pdf->SetTextColor(0, 0, 0);
//$pdf->SetXY(50, 30);
//$pdf->Write(0, 'This is just a simple text');
$pdf->SetY(53);
$pdf->Cell(58);
$pdf->Cell(126,20,$name,0,1,'C');
$pdf->SetFont('DroidSansFallback','', 19);
$pdf->writeHTMLCell(120, 15, 72, 84, $course, '1', 1, 1, true, 'C', true);
$pdf->SetFont('DroidSansFallback','', 18);
$pdf->SetY(96);
$pdf->Cell(60);
$pdf->Cell(120,15,$finishtime,0,1,'C');
$pdf->SetFont('DroidSansFallback','', 18);
$pdf->SetY(111);
$pdf->Cell(60);
$pdf->Cell(120,15,$catname,0,1,'C');
$pdf->SetFont('DroidSansFallback','', 18);
$pdf->SetY(127);
$pdf->Cell(60);
$pdf->Cell(120,15,$rank_cat,0,1,'C');
$pdf->SetFont('DroidSansFallback','', 18);
$pdf->SetY(143 );
$pdf->Cell(60);
$pdf->Cell(120,15,$rank_course,0,1,'C');
$filename = "UTMT210617 Certificate " . $runner['bibno_display'] . ' ' . $name . ".pdf";
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output($filename , 'I');
//============================================================+
// END OF FILE
//============================================================+